﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CrmWorkflowDependencies.Dependencies
{
    class HashtableVertex : Vertex
    {
        public override string Label
        {
            get
            {
                if (Components.Count == 1)
                {
                    return Components.First().Value;
                }
                return string.Format("{{ {0} }}", string.Join("| ", Components.Select( c=> string.Format("<{0}> {1}", c.Key, c.Value)).ToArray()));
            }
        }

        public Dictionary<string, string> Components = new Dictionary<string, string>();

        public void AddComponent(string port, string value)
        {
            if (!Components.ContainsKey(port))
            {
                Components.Add(port, value);
            }
        }

        public HashtableVertex(string alias) : base(alias) {
            Components.Add(alias, alias);
        }
    }
}
